<template>
  <div>
    <div class="comecharts"
    :style="{
        width: sendstyle.w,
        height: sendstyle.h,
        backgroundColor: sendstyle.b,
      }"
    ></div>
  </div>
</template>
<script>
import * as echarts from "echarts";
export default {
  props: {
    sendobj: {
      type: Object,
    },
    sendstyle: {
      type: Object,
    },
  },
 
  watch: {
    sendobj: {
    deep: true,
    handler() {
      // 基于准备好的dom，初始化echarts
      const myCharts = echarts.init(document.querySelector(".comecharts"));
      // 绘制图表
     const option = {
        title: {
          text: this.sendobj.title,
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985",
            },
          },
        },
        legend: {
          data:this.sendobj.legend.data,
        },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            data: this.sendobj.xAxis[0].data,
          },
        ],
        yAxis: this.sendobj.yAxis,
        series: this.sendobj.series,
        
      };
      myCharts.setOption(option);
    },
  },}
};
</script>

<style lang="less" scoped>
.comcharts {
  margin-top: 20px;
  border: 1px solid white;
}

</style>